<?php

Class AntiFurtoDAO{
    
    public function cadastrarAntiFurto(AntiFurto $antiFurto){
        
        try {

            //Banco de dados
            $conexao = new Conexao();
            $conn = $conexao->abrirConexao();

            //Codigo SQL
            $query = "
                INSERT INTO sistema_anti_furto (id, alarme_sonoro, bloqueio_ignicao, 
                    chave_codificada, daf_v, freio_carnceiro_similares, identificar, 
                    ituran_proprio, lojack_proprio, transponder, trava_manual, 
                    trava_mult_t_lock, trava_protecar, vacina, x3, corta_ignicao_automatico, 
                    corta_ignicao_manual) 
                VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
            ";
            
            //Cadastro
            $stmt = $conn->prepare($query);
            $stmt->bindValue(1, utf8_decode($antiFurto->getAlarmeSonoro()));
            $stmt->bindValue(2, utf8_decode($antiFurto->getBloqueioIngnicao()));
            $stmt->bindValue(3, utf8_decode($antiFurto->getChaveCodificada()));
            $stmt->bindValue(4, utf8_decode($antiFurto->getDafv()));
            $stmt->bindValue(5, utf8_decode($antiFurto->getFreioCarneiroSimilar()));
            $stmt->bindValue(6, utf8_decode($antiFurto->getIdentificar()));
            $stmt->bindValue(7, utf8_decode($antiFurto->getIturanProprio()));
            $stmt->bindValue(8, utf8_decode($antiFurto->getLojakProprio()));
            $stmt->bindValue(9, utf8_decode($antiFurto->getTranspoder()));
            $stmt->bindValue(10, utf8_decode($antiFurto->getTravaManual()));
            $stmt->bindValue(11, utf8_decode($antiFurto->getTravaMult()));
            $stmt->bindValue(12, utf8_decode($antiFurto->getTravaProtecar()));
            $stmt->bindValue(13, utf8_decode($antiFurto->getVacina()));
            $stmt->bindValue(14, utf8_decode($antiFurto->getX3()));
            $stmt->bindValue(15, utf8_decode($antiFurto->getCortaIgnicaoAutomatico()));
            $stmt->bindValue(16, utf8_decode($antiFurto->getCortaIgnicaoManual()));
            $stmt->execute();

            $idAntiFruto = $conn->lastInsertId();
            
            $conn = $conexao->fecharConexao();
            return $idAntiFruto;
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
            return false;
        }
    }
}

?>
